<?php


namespace EasySwoole\EasySwoole;


use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\Utility\File;

class EasySwooleEvent implements Event
{
    //项目入口 初始启动
    public static function initialize()
    {
        date_default_timezone_set('Asia/Shanghai');
        self::loadConf(EASYSWOOLE_ROOT . '/Config');
    }

    public static function mainServerCreate(EventRegister $register)
    {

    }

    public static function loadConf($ConfPath)
    {
        $Conf = Config::getInstance();
        //注意这个file需要引入的  这里的scandirectory与2.x的sacnDir一样注意修改

        $files = File::scanDirectory($ConfPath);
        //获取所有Config下所有的文件*/
        foreach ($files['files'] as $file) {
            $data = require_once $file;
            $Conf->setConf(strtolower(basename($file,'.php')),(array)$data);
        }
    }
}